package com.shuzixiangcun.service.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shuzixiangcun.entity.JobPostings;
import com.shuzixiangcun.dao.JobPostingsDao;
import com.shuzixiangcun.entity.Users;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 招工表(JobPostings)表服务实现类
 *
 * @author makejava
 * @since 2024-06-24 08:26:16
 */
@Service
public class JobPostingsServiceImpl {
    @Resource
    private JobPostingsDao jobPostingsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param jobId 主键
     * @return 实例对象
     */

    public JobPostings queryById(Integer jobId) {
        return this.jobPostingsDao.queryById(jobId);
    }

    /**
     * 分页查询
     *
     * @param jobPostings 筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */


    /**
     * 新增数据
     *
     * @param jobPostings 实例对象
     * @return 实例对象
     */

    public JobPostings insert(JobPostings jobPostings) {
        this.jobPostingsDao.insert(jobPostings);
        return jobPostings;
    }

    /**
     * 修改数据
     *
     * @param jobPostings 实例对象
     * @return 实例对象
     */

    public JobPostings update(JobPostings jobPostings) {
        this.jobPostingsDao.update(jobPostings);
        return this.queryById(jobPostings.getJobId());
    }

    /**
     * 通过主键删除数据
     *
     * @param jobId 主键
     * @return 是否成功
     */

    public boolean deleteById(Integer jobId) {
        return this.jobPostingsDao.deleteById(jobId) > 0;
    }


    public List<JobPostings> queryListJobPostings(String job_title) {
        return this.jobPostingsDao.getListJobPostings(job_title);
    }

    public PageInfo<JobPostings> getPageInfo(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize,true);
        List<JobPostings> mangerList=jobPostingsDao.getJobPostingsList();
        return new PageInfo<JobPostings>(mangerList);
    }

    public int updateByState(JobPostings jobPostings) {

        return this.jobPostingsDao.updateByState(jobPostings);
    }
}
